package cn.iocoder.yudao.module.digital.enums.cardkeysecret;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 属性值类型
 *
 * @author lizhognwen
 */
@Getter
@AllArgsConstructor
public enum CardKeySourceEnum {
    MANUAL(0, "manual", "采购"),
    BLACK_HAWK_API(1, "bh", "黑鹰API"),
    BAMBOO_API(2, "bamboo", "Bamboo API");

    private final Integer value;
    private final String key;
    private final String desc;

    // Jackson deserialization method
    @JsonCreator
    public static CardKeySourceEnum fromValue(Integer value) {
        for (CardKeySourceEnum source : CardKeySourceEnum.values()) {
            if (source.getValue().equals(value)) {
                return source;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }

    // Jackson serialization method
    @JsonValue
    public Integer getValue() {
        return value;
    }

    public static void main(String[] args) {
        CardKeySourceEnum cardKeySourceEnum = CardKeySourceEnum.fromValue(0);
        System.out.println(cardKeySourceEnum);
    }

}
